package cn.fl.ass.service.impl;

import fl.ass.facade.condition.AssDealCarCostQueryCondition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.ass.service.IAssDealCarCostService;
import cn.fl.ass.service.IAssDealCarService;
import cn.fl.ass.transform.AssDealCarCostVOTransform;
import cn.fl.ass.vo.AssDealCarCostVO;
import cn.fl.framework.base.context.CurrentThreadContext;
import fl.ass.facade.api.IAssDealCarApi;
import fl.ass.facade.dto.AssDealCarCostDTO;
import fl.ass.facade.dto.MessageDTO;

import java.util.List;

/**
 * @Description: 处置-转优车费用信息表 客户端服务层接口实现
 * @Description: 业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 */
@Service
public class AssDealCarCostServiceImpl implements IAssDealCarCostService {

	/**
	 * 日志
	 */
	private static final Logger logger = LoggerFactory.getLogger(IAssDealCarService.class);
	
	/**
	 * TODO 自定义 API 暴露服务
	 */
	@Autowired
	private IAssDealCarApi assDealCarApi;

	/**
	 * 保存（处置-转优车费用信息表）
	 */
	@Override
	public Long saveAssDealCarCost(AssDealCarCostVO entity) {
		if(null == entity){
			return null;
		}
		//返回新增ID值-JL-20170331
		MessageDTO<String> response = this.assDealCarApi.saveASSDealCarCost(AssDealCarCostVOTransform.toDTO(entity));
		return response.getId();
	}
	/**
	 * 分页查询（处置-转优车费用信息表）
	 */
	@Override
	public Pager findAssDealCarCostListByPage(Pager page) {
		if(null == page)page = new Pager();
		return this.assDealCarApi.findAssDealCarCostListByPage(page);
	}
	/**
	 * 删除（处置-转优车费用信息表）
	 */
	@Override
	public boolean removeById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			return false;
		}
		MessageDTO<String> response = this.assDealCarApi.removeById(id);
		return response.isSuccess();
	}
	/**
	 * 查询（处置-转优车费用信息表）
	 */
	@Override
	public AssDealCarCostVO selectById(Long id) throws BaseException {
		if(StringUtils.isEmpty(id)){
			return null;
		}
		//TODO 业务逻辑
		MessageDTO<AssDealCarCostDTO> dto = this.assDealCarApi.selectAssDealCarCostById(id);
		return AssDealCarCostVOTransform.toVO(dto.getData());
	}
	
	/**
	 * 修改（处置-转优车费用信息表）
	 */
	@Override
	public boolean modify(AssDealCarCostVO entity) throws BaseException {
		if(null == entity){
			return false;
		}
		MessageDTO<String> response = this.assDealCarApi.modifyAssDealCarCost(AssDealCarCostVOTransform.toDTO(entity));
		
		return response.isSuccess();
	}

    @Override
    public List<AssDealCarCostDTO> searchAssDealCarCostList(AssDealCarCostQueryCondition qc) throws BaseException {
        return this.assDealCarApi.searchAssDealCarCostList(qc);
    }
}
